package com.mali.api.config;

import com.mali.common.util.UserContext;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.context.annotation.Configuration;

import java.util.Objects;

@Configuration
public class RequestConfig implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        Long userId = UserContext.getUserId();
        if(Objects.nonNull(userId)){
            requestTemplate.header("userId", String.valueOf(userId));
        }
    }
}
